package ch.bfh.abcmmh.controller.operating.scanner;

import ch.bfh.abcmmh.controller.operating.interfaces.IStreetScanner;
import ch.bfh.abcmmh.model.street.Street;

public class StreetScanner implements IStreetScanner {

	protected Street street;

	public StreetScanner(Street street) {
		this.street = street;
	}

	@Override
	public int getDistObstacleAhead(int actualPosition) {
		int freePositions = 0;
		if (street.getHighestIndex() != actualPosition) {
			while (street.getSAttribute(++actualPosition).isFree()) {

				freePositions++;

				if (street.getHighestIndex() == actualPosition) {
					// craphack
					return 200;
				}
			}
		} else if (street.getHighestIndex() == actualPosition) {
			// craphack
			return 200;
		}
		return freePositions;
	}

	@Override
	public int getDistObstacleBehind(int actualPosition) {
		// TODO Auto-generated method stub
		return 0;
	}

}
